package com.example.IoCpractice.component;

import com.example.IoCpractice.model.UserInfo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-12
 * Time: 16:35
 */
@Component
public class UserInfoComponent {
    @Bean({"zhangsan","userInfo"})
    public UserInfo userInfo() {
        return new UserInfo("zhangsan",18);
    }

    @Bean(name = {"lisi","userInfo1"})
    public UserInfo userInfo1() {
        return new UserInfo("lisi",17);
    }

    //@Primary
    @Bean("wangwu")
    public UserInfo userInfo2() {
        return new UserInfo("wangwu",19);
    }


    @Bean
    public String name1() {
        return "text";
    }

    @Bean
    //@Primary
    public String name2() {
        return "tianqi";
    }
    @Bean
    public UserInfo userInfo3(@Qualifier("name1") String name3) {
        return new UserInfo(name3,20);
    }
}
